#!/usr/bin/env bash


# https://blog.csdn.net/wohendatou/article/details/102028632
yum install -y wget
#获取大版本 8
version = `cat /etc/redhat-release | awk '{print $4}'| awk -F '.' '{print $1}'`

# 获取8.2
# rpm -qi centos-release | grep Version | awk '{print $3}'
if [ $version == "7"]
then
  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-$version.repo
  wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-$version.repo
  wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
else
  sed -i "s|^mirrorlist|#mirrorlist|g" /etc/yum.repos.d/CentOS-AppStream.repo
  sed -i "s|mirror.centos.org|mirrors.aliyun.com/centos|g" /etc/yum.repos.d/CentOS-AppStream.repo

  sed -i "s|^mirrorlist|#mirrorlist|g" /etc/yum.repos.d/CentOS-Base.repo
  sed -i "s|mirror.centos.org|mirrors.aliyun.com/centos|g" /etc/yum.repos.d/CentOS-Base.repo

  sed -i "s|^mirrorlist|#mirrorlist|g" /etc/yum.repos.d/CentOS-Extras.repo
  sed -i "s|mirror.centos.org|mirrors.aliyun.com/centos|g" /etc/yum.repos.d/CentOS-Extras.repo
fi


yum clean all
yum makecache

systemctl disable firewalld
systemctl stop firewalld

yum install -y htop net-tools vi curl

chmod a+rw -R /opt/

# 修改linux最大打开文件数ulimit
# 查看： limit -n

echo "* soft nofile 65535" >>/etc/security/limits.conf
echo "* hard nofile 65535" >>/etc/security/limits.conf

echo "完成。"


# curl -fsSL http://dev8.cn:8000/static/ops/centos-server.sh | bash